package com.xingmang.admin.controller;

import com.xingmang.admin.service.DicService;
import com.xingmang.common.constant.PageEntity;
import com.xingmang.common.constant.ResultBean;
import com.xingmang.common.dto.admin.DicListDTO;
import com.xingmang.common.dto.admin.DicPageDTO;
import com.xingmang.common.dto.admin.DicSaveDTO;
import com.xingmang.common.vo.admin.DicPageVO;
import com.xingmang.common.vo.admin.DicVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @auther: hansom
 * @Version: 1.0
 * @create 2023/6/20 16:57
 */
@RestController
@RequestMapping("/admin/dic")
@Api(tags = "字典代码")
public class DicController {

    @Resource
    private DicService dicService;

    @PostMapping("page")
    @ApiOperation("分页")
    public ResultBean<PageEntity<DicPageVO>> page(@RequestBody @Validated DicPageDTO dto){
        return dicService.page(dto);
    }

    @PostMapping("list")
    @ApiOperation("列表")
    public ResultBean<List<DicVO>> list(@RequestBody @Validated DicListDTO dto){
        return dicService.list(dto);
    }

    @PostMapping("save")
    @ApiOperation("新增")
    public ResultBean save(@RequestBody @Validated DicSaveDTO dto){
        return dicService.save(dto);
    }
}
